<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ include file="../common/tags.jsp"%>
<%
	String path = request.getContextPath();
%>
<script>
function searchEntityForm(obj) {
	if('${searchType}' == '') {
			return navTabSearch(obj);
		}
	else {
		return dwzSearch(obj, 'dialog');
	}
}
</script>
<form id="pagerForm" method="post" action="<%=path %>/favourableEntity/listFavourableEntity.action">
	<input type="hidden" name="pageRequest" value="1" />
	<input type="hidden" name="pageNum" value="${paginator.pageIndex}" />
	<input type="hidden" name="numPerPage" value="${paginator.pageSize}" />
</form>

<div class="pageHeader">
	<form onsubmit="return searchEntityForm(this);" rel="pagerForm" action="<%=path %>/favourableEntity/listFavourableEntity.action" method="post">
	<input type="hidden" name="searchType" value="${searchType}"/>
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">优惠券名：</label>
				<input type="text" name="favourableEntityVO.name" value="${favourableEntityVO.name}"/>
			</li>
			<li>
				<label style="text-align: right;">编码：</label>
				<input name="favourableEntityVO.code" type="text"  value="${favourableEntityVO.code}"/>
			</li>
			<li>
				<label style="text-align: right;">优惠券种类：</label>
				<s:select name="favourableEntityVO.classification" list="%{#{'':'请选择',1:'专用型',0:'普惠制'}}" listKey="key" listValue="value" id="classification"></s:select>
			</li>
		</ul>
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">优惠券类别：</label>
				<select name="favourableEntityVO.favourableTypeId"> 
				<option value="">请选择</option>
				<c:forEach items="${favourableTypeList}" var="favourableTypeVO">
					<option value="${favourableEntityVO.favourableTypeId}">${favourableTypeVO.favourableType}</option>
				</c:forEach>
				</select>
			</li>
			<li>
				<label style="text-align: right;">发送渠道：</label>
				<s:select name="favourableEntityVO.releaseChannel" list="%{#{'':'请选择',0:'全部',1:'商家发送',2:'自主申请'}}" listKey="key" listValue="value" id="releaseChannel"></s:select>
			</li>
			<li>
				<label style="text-align: right;">发送数量：</label>
				从<input type="text" name="favourableEntityVO.gtamount" value="<s:property value="favourableEntityVO.gtamount" />" size="5"/>
				到<input type="text" name="favourableEntityVO.ltamount" value="<s:property value="favourableEntityVO.ltamount" />" size="5"/>
			</li>
		</ul>
		<ul class="searchContent">
			<c:choose>
			<c:when test="${customerId==null}">
			<c:choose>
				<c:when test="${SESSION_USER.customer==null}">
					<input name="favourableEntityVO.customerId" value="${favourableEntityVO.customerId}" type="hidden">
					<c:if test="${searchType==null||searchType==''}">
						<li>
							<label style="text-align: right;">所属商家：</label>
							<input onclick="$('#favourableEntityList_a_btnLook').click();" name="favourableEntityVO.customerName" style="cursor: pointer;float: left;" value="<s:property value="favourableEntityVO.customerName" />"/>
							<!-- <a class="btnLook" id="favourableEntityList_a_btnLook" href="<%=path%>/customer/listCustomer.action?searchType=favourableEntity" lookupGroup="favourableEntityVO">选择</a> -->
						</li>
					</c:if>
				</c:when>
				<c:otherwise>
					<input name="favourableEntityVO.customerId" value="${SESSION_USER.customer.id}" type="hidden">
				</c:otherwise>
			</c:choose>
			</c:when>
			<c:otherwise>
				<input type="hidden" name="customerId" value="${customerId}"/>
			</c:otherwise>
			</c:choose>
			<li style="width:450px">
				<label style="text-align: right;">开始时间：</label>
				从<input type="text" name="favourableEntityVO.gtuseBegDate" value='<s:date name='favourableEntityVO.gtuseBegDate' format="yyyy-MM-dd HH:mm:ss"/>' dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
				到<input type="text" name="favourableEntityVO.ltuseBegDate" value='<s:date name='favourableEntityVO.ltuseBegDate' format="yyyy-MM-dd HH:mm:ss"/>' dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
			</li>
		</ul>
		<ul class="searchContent">
			<li style="width:450px">
				<label style="text-align: right;">结束时间：</label>
				从<input type="text" name="favourableEntityVO.gtuseEndDate" value='<s:date name='favourableEntityVO.gtuseEndDate' format="yyyy-MM-dd HH:mm:ss"/>' dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
				到<input type="text" name="favourableEntityVO.ltuseEndDate" value='<s:date name='favourableEntityVO.ltuseEndDate' format="yyyy-MM-dd HH:mm:ss"/>' dateFmt="yyyy-MM-dd HH:mm:ss" class="date" readonly="false"/>
			</li>
		</ul>
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
	 <c:if test="${searchType == null || searchType == ''}">
		<ul class="toolBar">
		<shiro:hasPermission name="addFavourableEntity">
			<li><a class="add" href="<%=path %>/favourableEntity/addFavourableEntity.action" target="navTab"><span>添加</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="deleteFavourable">
			<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" tbName="favourable_entity" postType="string" href="<%=path %>/favourableEntity/deleteFavourableEntity.action" class="delete"><span>删除</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="editFavourableEntity">
			<li><a class="edit" href="<%=path %>/favourableEntity/editFavourableEntity.action?favourableEntityVO.id={sid_user}" target="navTab" warn="请选择一条记录"><span>修改</span></a></li>
			</shiro:hasPermission>
		</ul>
		</c:if>
	</div>
	<table class="table" width="1150" layoutH="214">
		<thead>
			<tr>
				 <c:if test="${searchType == null || searchType == ''}">
				<th width="30"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				</c:if>
				<th>优惠券名</th>
				<th>所属商家</th>
				<th width="90">代金券金额</th>
				<th>优惠券简要描述</th>
				<th  width="150">优惠券开始使用时间</th>
				<th  width="150">优惠券结束使用时间</th>
				<th  width="100">是否到期提醒</th>
				<th width="120">是否手机使用验证</th>
				<th width="80">发送数量</th>
				<c:if test="${searchType == null || searchType == ''}">
				<th width="90">操作</th>
				</c:if>
				<c:if test="${searchType != null && searchType != ''}">
				<th>查找带回</th>
				</c:if>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="favourableEntityList" id="favourableEntity" status="st">
				<tr target="sid_user" rel="<s:property value="id" />">
			 <c:if test="${searchType == null || searchType == ''}">
			 	<td>
			 		<input name="ids" value="<s:property value="id" />" type="checkbox"/>
			 	</td>
			 </c:if>
             <td><s:property value="name" /></td>
             <td><s:property value="customerName" /></td>	
             <td><s:property value="value" /></td>	
             <td><s:property value="simpleDescription" /></td>
			 <td><s:date name="useBegDate" format="yyyy-MM-dd HH:mm:ss" /></td>
	         <td><s:date name="useEndDate" format="yyyy-MM-dd HH:mm:ss" /></td>
             <td>
             <s:if test="%{#favourableEntity.isRemind == 1}">是</s:if>
                 <s:else>否</s:else>
             </td>
             <td>
             <s:if test="%{#favourableEntity.isAuthenByMoblie == 1}">是</s:if>
                 <s:else>否</s:else>
             </td>
             <td>
              <s:property value="amount" />
             </td>
             <c:if test="${searchType == null || searchType == ''}">
				<td>
					<shiro:hasPermission name="deleteFavourableEntity">
						<a title="确实要删除这条记录吗?" target="ajaxTodo" tbName="favourable_entity" ids="${id}" href="<%=path %>/favourableEntity/deleteFavourableEntity.action?ids=<s:property value="id" />" class="btnDel">删除</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="editFavourableEntity">
						<a title="编辑" target="navTab" href="<%=path %>/favourableEntity/editFavourableEntity.action?favourableEntityVO.id=<s:property value="id" />" class="btnEdit">编辑</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="viewFavourableEntity">
						<a class="btnView" title="详情" target="navTab" href="<%=path %>/favourableEntity/viewFavourableEntity.action?favourableEntityVO.id=<s:property value="id" />" >详情</a>
					</shiro:hasPermission>
					</td>
			</c:if>
			<c:if test="${searchType == 'favourable'}">
				<td>
					<a class="btnSelect" href="javascript:$.bringBack({favourableEntityId:'${favourableEntity.id}', favourableEntityName:'${favourableEntity.name}'})" title="查找带回">选择</a>
				</td>
			</c:if>
			<c:if test="${searchType=='advertising'}">
				<td>
					<a class="btnSelect" href="javascript:$.bringBack({linkId:'${favourableEntity.id}', favourableName:'${favourableEntity.name}'})" title="查找带回">选择</a>
				</td>
			</c:if>
			</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" onchange='<s:if test="%{searchType==null||searchType==''}">navTabPageBreak({numPerPage:this.value})</s:if><s:else>dialogPageBreak({numPerPage:this.value})</s:else>'>
					<option value="15" <c:if test="${paginator.pageSize==15}">selected='selected'</c:if> >15</option>
					<option value="30" <c:if test="${paginator.pageSize==30}">selected='selected'</c:if> >30</option>
					<option value="50" <c:if test="${paginator.pageSize==50}">selected='selected'</c:if> >50</option>
					<option value="100" <c:if test="${paginator.pageSize==100}">selected='selected'</c:if> >100</option>
					<option value="200" <c:if test="${paginator.pageSize==200}">selected='selected'</c:if> >200</option>
				</select>
				<span>条，共${paginator.totalCount}条</span>
			</div>
			<div class="pagination" targetType="${(searchType==null||searchType=='')?'navTab':'dialog'}" totalCount="${paginator.totalCount}" 
				numPerPage="${paginator.pageSize}" pageNumShown="10" currentPage="${paginator.pageIndex}"></div>
	</div>
</div>